<?php

class Plantform{

	/**
	 * 添加
	 *
	 * @param unknown_type $name
	 * @param unknown_type $parent
	 * @param unknown_type $ord
	 */
	function add($data){
		
		$m = M('Plantform');
		//返回自增id
		$id = $m->add($data);
		
		return $id;
	}
	
	/**
	 * 修改
	 *
	 * @param unknown_type $id
	 * @param unknown_type $upItems
	 * @return unknown
	 */
	function update($id,$upItems){
		$m = M('Plantform');
		return $m -> where('plantform_id='.$id)->save($upItems);
	}
	
	function get_by_id($id){
		$m = M('Plantform');
		return $m -> getByPlantformId($id);
	}

	function lists(){
		
		$m = M('Plantform');
		return $m->order('plantform_id ASC')
		->select();
	}

	/**
	 * 
	 * 名称和id的映射
	 */
	function maps(){	
		
		$plantforms = $this->lists();
		
		$maps = array();
		
		foreach($plantforms as $i => $p){
			$maps[$p['plantform_name']] = $p['plantform_id'];
		}
		
		return $maps;
	}
	
}